<template>
	<div class="border border-[#FFB848]">
		<div class="bg-[#FFB848] text-[#fafafa] text-base p-2 flex flex-wrap">
			<div class="w-1/2 pl-2">{{ $t('report.sales.overview') }} </div>
			<div class="w-1/2 text-right pr-2"> {{ $t('report.sales.Lasttime') }} ( {{ getPlevel.gettime(item.time, 3) }}
				)</div>
		</div>

		<div class="m-2 border">

			<el-row class="bg-[#FFEBCD]">
				<el-col :span="3" class="border-r border-b p-2">{{ $t('report.sales.totalSales') }}</el-col>
				<el-col :span="3" class="border-r border-b p-2">{{ item.totalPrice * 1 || '0' }}</el-col>
				<el-col :span="3" class="border-r border-b p-2">{{ $t('report.sales.salesVolume') }}</el-col>
				<el-col :span="3" class="border-r border-b p-2">{{ item.totalQuantity || '0' }}</el-col>
				<el-col :span="3" class="border-r border-b p-2">{{ $t('order.consume.ordersNum') }}</el-col>
				<el-col :span="3" class="border-r border-b p-2">{{ item.order_num || '0' }}</el-col>
				<el-col :span="3" class="border-r border-b p-2"></el-col>
				<el-col :span="3" class="border-r border-b p-2"></el-col>
			</el-row>

			<el-row>
				<el-col :span="3" class="border-r border-b p-2">{{ $t('report.sales.machineSales') }}</el-col>
				<el-col :span="3" class="border-r border-b p-2">{{ item.totalPrice * 1 || '0' }}</el-col>
				<el-col :span="3" class="border-r border-b p-2">{{ $t('report.sales.machineSalesVolume') }}</el-col>
				<el-col :span="3" class="border-r border-b p-2">{{ item.totalQuantity || '0' }}</el-col>
				<el-col :span="3" class="border-r border-b p-2">{{ $t('report.sales.machineOder') }}</el-col>
				<el-col :span="3" class="border-r border-b p-2">{{ item.order_num || '0' }}</el-col>
				<el-col :span="3" class="border-r border-b p-2">{{ $t('report.sales.totalGifts') }}</el-col>
				<el-col :span="3" class="border-r border-b p-2">{{ item.giftQuantity || '0' }}</el-col>
			</el-row>

			<el-row>
				<el-col :span="3" class="border-r border-b p-2">{{ $t('report.sales.salesDraw') }}</el-col>
				<el-col :span="3" class="border-r border-b p-2">{{ item.lotteryAmount * 1 || '0.00' }}</el-col>
				<el-col :span="3" class="border-r border-b p-2">{{ $t('report.sales.salesDrawVolume') }}</el-col>
				<el-col :span="3" class="border-r border-b p-2">{{ item.lotteryQuantity || '0' }}</el-col>
				<el-col :span="3" class="border-r border-b p-2">{{ $t('report.sales.lotteryOrder') }}</el-col>
				<el-col :span="3" class="border-r border-b p-2">{{ item.lottery_used || '0' }}</el-col>
				<el-col :span="3" class="border-r border-b p-2">{{ $t('report.sales.couponsTotal') }}</el-col>
				<el-col :span="3" class="border-r border-b p-2">{{ item.coupon_used || '0' }}</el-col>
			</el-row>

			<el-row>
				<el-col :span="3" class="border-r border-b p-2">{{ $t('order.payment.refundAmount') }}</el-col>
				<el-col :span="3" class="border-r border-b p-2">{{ item.totalRefundAmount * 1 || '0.00' }}</el-col>
				<el-col :span="3" class="border-r border-b p-2">{{ $t('report.sales.return') }}</el-col>
				<el-col :span="3" class="border-r border-b p-2">{{ item.totalRefundQuantity || '0' }}</el-col>
				<el-col :span="3" class="border-r border-b p-2"></el-col>
				<el-col :span="3" class="border-r border-b p-2"></el-col>
				<el-col :span="3" class="border-r border-b p-2"></el-col>
				<el-col :span="3" class="border-r border-b p-2"></el-col>
			</el-row>
			<el-row>
				<el-col :span="3" class="border-r border-b p-2">{{ $t('home.discountAmount') }}</el-col>
				<el-col :span="3" class="border-r border-b p-2">{{ item.totalDiscountPrice * 1 || '0.00' }}</el-col>
				<el-col :span="3" class="border-r border-b p-2"></el-col>
				<el-col :span="3" class="border-r border-b p-2"></el-col>
				<el-col :span="3" class="border-r border-b p-2"></el-col>
				<el-col :span="3" class="border-r border-b p-2"></el-col>
				<el-col :span="3" class="border-r border-b p-2"></el-col>
				<el-col :span="3" class="border-r border-b p-2"></el-col>
			</el-row>

			<el-row class="bg-[#FFEBCD]">
				<el-col :span="3" class="border-r p-2">{{ $t('report.sales.actual') }}</el-col>
				<el-col :span="3" class="border-r p-2">{{ getrevenue() }}</el-col>
				<el-col :span="3" class="border-r p-2">{{ $t('report.sales.actualVolume') }}</el-col>
				<el-col :span="3" class="border-r p-2">{{ getvolume() }}</el-col>
				<el-col :span="3" class="border-r p-2">{{ $t('report.sales.unitPrice') }}</el-col>
				<el-col :span="3" class="border-r p-2">{{ getprice() }}</el-col>
				<el-col :span="3" class="border-r p-2"></el-col>
				<el-col :span="3" class="border-r p-2"></el-col>
			</el-row>

		</div>

	</div>
</template>

<script lang="ts" setup>
import { useI18n } from 'vue-i18n'
const { t: $t } = useI18n()
import getPlevel from '@/utils/level'
let props = defineProps({
	item: {
		type: Object,
		default: {}
	}
})

let data = reactive({
	money: '0.00',
	num: '0'
})

// 实际销售额
let getrevenue = () => {
	let money = '0.00'
	let Price = props.item.totalPrice * 1 || 0
	let Amount = props.item.totalRefundAmount * 1 || 0
	let Discount = props.item.totalDiscountPrice *1 || 0
	money = Price - Amount - Discount
	data.money = money
	return Number(money).toFixed(2)
}

// 实际销售量
let getvolume = () => {
	let num = 0
	let Quantity = props.item.totalQuantity * 1 || 0
	let Refund = props.item.totalRefundQuantity * 1 || 0
	num = Quantity - Refund
	data.num = num
	return num
}

// 客单价
let getprice = () => {
	let price = '0.00'
	let money = data.money * 1 || 0
	let num = data.num * 1 || 0
	price = money / num

	if (isNaN(price)) {
		price = '0.00'
	} else {
		price = price.toFixed(2)
	}
	return price
}

</script>
